{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "2c21e028",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "data_edges = pd.read_csv(\"m-a_edges1.csv\",encoding=\"utf8\")\n",
    "data_api = pd.read_csv(\"api_nodes_estimator1.csv\",index_col = 1,encoding=\"utf8\")\n",
    "data_mashup = pd.read_csv(\"mashup_nodes_estimator1.csv\",index_col = 2,encoding=\"utf8\")\n",
    "\n",
    "# m_a_edges=\"m-a_edges.csv\"\n",
    "# data_edges=pd.read_csv(m_a_edges, encoding=\"utf-8\",sep='\\t', error_bad_lines=False)\n",
    "\n",
    "# api_nodes_estimator=\"api_nodes_estimator.csv\"\n",
    "# data_api=pd.read_csv(api_nodes_estimator, index_col = 1,encoding=\"utf-8\",sep='\\t',error_bad_lines=False)\n",
    "\n",
    "# mashup_nodes_estimator=\"mashup_nodes_estimator1.csv\"\n",
    "# data_mashup=pd.read_csv(mashup_nodes_estimator, index_col = 2,encoding=\"utf-8\",sep='\\t',error_bad_lines=False)\n",
    "# print(data_mashup)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "e185fa84",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>source</th>\n",
       "      <th>target</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Mashup: CouponRoots</td>\n",
       "      <td>/api/coupon</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Mashup: Raise the Money</td>\n",
       "      <td>/api/nationbuilder</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Mashup: AnythingToHTML</td>\n",
       "      <td>/api/hpe-haven-ondemand-view-document</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Mashup: Velocipedia</td>\n",
       "      <td>/api/mapbox</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Mashup: Api Expert - MyMemory Language Translator</td>\n",
       "      <td>/api/mymemory</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12609</th>\n",
       "      <td>Mashup: Libraries411</td>\n",
       "      <td>/api/geocoder</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12610</th>\n",
       "      <td>Mashup: Libraries411</td>\n",
       "      <td>/api/geocoderca</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12611</th>\n",
       "      <td>Mashup: National Geographic Map Machine</td>\n",
       "      <td>/api/globexplorer</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12612</th>\n",
       "      <td>Mashup: Splashr</td>\n",
       "      <td>/api/flickr</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12613</th>\n",
       "      <td>Mashup: Smarkets</td>\n",
       "      <td>/api/amazon-product-advertising</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>12614 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                  source  \\\n",
       "0                                    Mashup: CouponRoots   \n",
       "1                                Mashup: Raise the Money   \n",
       "2                                 Mashup: AnythingToHTML   \n",
       "3                                    Mashup: Velocipedia   \n",
       "4      Mashup: Api Expert - MyMemory Language Translator   \n",
       "...                                                  ...   \n",
       "12609                               Mashup: Libraries411   \n",
       "12610                               Mashup: Libraries411   \n",
       "12611            Mashup: National Geographic Map Machine   \n",
       "12612                                    Mashup: Splashr   \n",
       "12613                                   Mashup: Smarkets   \n",
       "\n",
       "                                      target  \n",
       "0                                /api/coupon  \n",
       "1                         /api/nationbuilder  \n",
       "2      /api/hpe-haven-ondemand-view-document  \n",
       "3                                /api/mapbox  \n",
       "4                              /api/mymemory  \n",
       "...                                      ...  \n",
       "12609                          /api/geocoder  \n",
       "12610                        /api/geocoderca  \n",
       "12611                      /api/globexplorer  \n",
       "12612                            /api/flickr  \n",
       "12613        /api/amazon-product-advertising  \n",
       "\n",
       "[12614 rows x 2 columns]"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_edges=data_edges.drop(columns=['Unnamed: 2','Unnamed: 3'])\n",
    "data_edges"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "e636755d",
   "metadata": {},
   "outputs": [],
   "source": [
    "api_c=[]\n",
    "for url in data_edges['target']:\n",
    "    if url in data_api.index.values:\n",
    "        api_c.append(data_api.loc[url]['c'])\n",
    "    else:\n",
    "        api_c.append('NaN')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "3d3dbdb3",
   "metadata": {},
   "outputs": [],
   "source": [
    "mashup_c=[]\n",
    "for mashup in data_edges['source']:\n",
    "    #print(mashup)\n",
    "    #print(dt3.loc[mashup]['c'])\n",
    "    if mashup in data_mashup.index.values:\n",
    "        mashup_c.append(data_mashup.loc[mashup]['c'])\n",
    "    else:\n",
    "        mashup_c.append('NaN')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "0015fd98",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>source</th>\n",
       "      <th>target</th>\n",
       "      <th>mashup_c</th>\n",
       "      <th>api_c</th>\n",
       "      <th>num</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Mashup: CouponRoots</td>\n",
       "      <td>/api/coupon</td>\n",
       "      <td>Coupons</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Mashup: Raise the Money</td>\n",
       "      <td>/api/nationbuilder</td>\n",
       "      <td>Funding</td>\n",
       "      <td>Social</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Mashup: AnythingToHTML</td>\n",
       "      <td>/api/hpe-haven-ondemand-view-document</td>\n",
       "      <td>Documents</td>\n",
       "      <td>Documents</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Mashup: Velocipedia</td>\n",
       "      <td>/api/mapbox</td>\n",
       "      <td>Mapping</td>\n",
       "      <td>Mapping</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Mashup: Api Expert - MyMemory Language Translator</td>\n",
       "      <td>/api/mymemory</td>\n",
       "      <td>Translation</td>\n",
       "      <td>Tools</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12609</th>\n",
       "      <td>Mashup: Libraries411</td>\n",
       "      <td>/api/geocoder</td>\n",
       "      <td>Mapping</td>\n",
       "      <td>Mapping</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12610</th>\n",
       "      <td>Mashup: Libraries411</td>\n",
       "      <td>/api/geocoderca</td>\n",
       "      <td>Mapping</td>\n",
       "      <td>Mapping</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12611</th>\n",
       "      <td>Mashup: National Geographic Map Machine</td>\n",
       "      <td>/api/globexplorer</td>\n",
       "      <td>Mapping</td>\n",
       "      <td>Mapping</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12612</th>\n",
       "      <td>Mashup: Splashr</td>\n",
       "      <td>/api/flickr</td>\n",
       "      <td>Photos</td>\n",
       "      <td>Photos</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12613</th>\n",
       "      <td>Mashup: Smarkets</td>\n",
       "      <td>/api/amazon-product-advertising</td>\n",
       "      <td>eCommerce</td>\n",
       "      <td>eCommerce</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>12614 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                  source  \\\n",
       "0                                    Mashup: CouponRoots   \n",
       "1                                Mashup: Raise the Money   \n",
       "2                                 Mashup: AnythingToHTML   \n",
       "3                                    Mashup: Velocipedia   \n",
       "4      Mashup: Api Expert - MyMemory Language Translator   \n",
       "...                                                  ...   \n",
       "12609                               Mashup: Libraries411   \n",
       "12610                               Mashup: Libraries411   \n",
       "12611            Mashup: National Geographic Map Machine   \n",
       "12612                                    Mashup: Splashr   \n",
       "12613                                   Mashup: Smarkets   \n",
       "\n",
       "                                      target     mashup_c      api_c  num  \n",
       "0                                /api/coupon      Coupons        NaN    0  \n",
       "1                         /api/nationbuilder      Funding     Social    0  \n",
       "2      /api/hpe-haven-ondemand-view-document    Documents  Documents    0  \n",
       "3                                /api/mapbox      Mapping    Mapping    0  \n",
       "4                              /api/mymemory  Translation      Tools    0  \n",
       "...                                      ...          ...        ...  ...  \n",
       "12609                          /api/geocoder      Mapping    Mapping    0  \n",
       "12610                        /api/geocoderca      Mapping    Mapping    0  \n",
       "12611                      /api/globexplorer      Mapping    Mapping    0  \n",
       "12612                            /api/flickr       Photos     Photos    0  \n",
       "12613        /api/amazon-product-advertising    eCommerce  eCommerce    0  \n",
       "\n",
       "[12614 rows x 5 columns]"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_edges['mashup_c'] = mashup_c\n",
    "data_edges['api_c'] = api_c\n",
    "data_edges['num'] = 0\n",
    "data_edges"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "fc23ed7d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>source</th>\n",
       "      <th>target</th>\n",
       "      <th>mashup_c</th>\n",
       "      <th>api_c</th>\n",
       "      <th>num</th>\n",
       "      <th>num2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Mashup: CouponRoots</td>\n",
       "      <td>/api/coupon</td>\n",
       "      <td>Coupons</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Mashup: Raise the Money</td>\n",
       "      <td>/api/nationbuilder</td>\n",
       "      <td>Funding</td>\n",
       "      <td>Social</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Mashup: AnythingToHTML</td>\n",
       "      <td>/api/hpe-haven-ondemand-view-document</td>\n",
       "      <td>Documents</td>\n",
       "      <td>Documents</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Mashup: Velocipedia</td>\n",
       "      <td>/api/mapbox</td>\n",
       "      <td>Mapping</td>\n",
       "      <td>Mapping</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Mashup: Api Expert - MyMemory Language Translator</td>\n",
       "      <td>/api/mymemory</td>\n",
       "      <td>Translation</td>\n",
       "      <td>Tools</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12609</th>\n",
       "      <td>Mashup: Libraries411</td>\n",
       "      <td>/api/geocoder</td>\n",
       "      <td>Mapping</td>\n",
       "      <td>Mapping</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12610</th>\n",
       "      <td>Mashup: Libraries411</td>\n",
       "      <td>/api/geocoderca</td>\n",
       "      <td>Mapping</td>\n",
       "      <td>Mapping</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12611</th>\n",
       "      <td>Mashup: National Geographic Map Machine</td>\n",
       "      <td>/api/globexplorer</td>\n",
       "      <td>Mapping</td>\n",
       "      <td>Mapping</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12612</th>\n",
       "      <td>Mashup: Splashr</td>\n",
       "      <td>/api/flickr</td>\n",
       "      <td>Photos</td>\n",
       "      <td>Photos</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12613</th>\n",
       "      <td>Mashup: Smarkets</td>\n",
       "      <td>/api/amazon-product-advertising</td>\n",
       "      <td>eCommerce</td>\n",
       "      <td>eCommerce</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>12614 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                  source  \\\n",
       "0                                    Mashup: CouponRoots   \n",
       "1                                Mashup: Raise the Money   \n",
       "2                                 Mashup: AnythingToHTML   \n",
       "3                                    Mashup: Velocipedia   \n",
       "4      Mashup: Api Expert - MyMemory Language Translator   \n",
       "...                                                  ...   \n",
       "12609                               Mashup: Libraries411   \n",
       "12610                               Mashup: Libraries411   \n",
       "12611            Mashup: National Geographic Map Machine   \n",
       "12612                                    Mashup: Splashr   \n",
       "12613                                   Mashup: Smarkets   \n",
       "\n",
       "                                      target     mashup_c      api_c  num  \\\n",
       "0                                /api/coupon      Coupons        NaN    0   \n",
       "1                         /api/nationbuilder      Funding     Social    0   \n",
       "2      /api/hpe-haven-ondemand-view-document    Documents  Documents    1   \n",
       "3                                /api/mapbox      Mapping    Mapping    1   \n",
       "4                              /api/mymemory  Translation      Tools    0   \n",
       "...                                      ...          ...        ...  ...   \n",
       "12609                          /api/geocoder      Mapping    Mapping    1   \n",
       "12610                        /api/geocoderca      Mapping    Mapping    1   \n",
       "12611                      /api/globexplorer      Mapping    Mapping    1   \n",
       "12612                            /api/flickr       Photos     Photos    1   \n",
       "12613        /api/amazon-product-advertising    eCommerce  eCommerce    1   \n",
       "\n",
       "       num2  \n",
       "0         1  \n",
       "1         1  \n",
       "2         1  \n",
       "3         1  \n",
       "4         1  \n",
       "...     ...  \n",
       "12609     1  \n",
       "12610     1  \n",
       "12611     1  \n",
       "12612     1  \n",
       "12613     1  \n",
       "\n",
       "[12614 rows x 6 columns]"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#如果mashup的属性和api的属性相同，那么num=1，否则num为0\n",
    "#num2作为计数项\n",
    "data_edges.loc[(data_edges.loc[:,'mashup_c'] == data_edges.loc[:,'api_c']),'num'] = 1\n",
    "data_edges['num2']=1\n",
    "data_edges"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "249103ce",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>num</th>\n",
       "      <th>num2</th>\n",
       "      <th>percent</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mashup_c</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Mapping</th>\n",
       "      <td>1064</td>\n",
       "      <td>1692</td>\n",
       "      <td>0.628842</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Social</th>\n",
       "      <td>304</td>\n",
       "      <td>771</td>\n",
       "      <td>0.394293</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>eCommerce</th>\n",
       "      <td>289</td>\n",
       "      <td>630</td>\n",
       "      <td>0.458730</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Music</th>\n",
       "      <td>259</td>\n",
       "      <td>653</td>\n",
       "      <td>0.396631</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Photos</th>\n",
       "      <td>251</td>\n",
       "      <td>549</td>\n",
       "      <td>0.457195</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Location</th>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Loyalty</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Lyrics</th>\n",
       "      <td>0</td>\n",
       "      <td>23</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Machine Learning</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3D</th>\n",
       "      <td>0</td>\n",
       "      <td>22</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>320 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                   num  num2   percent\n",
       "mashup_c                              \n",
       "Mapping           1064  1692  0.628842\n",
       "Social             304   771  0.394293\n",
       "eCommerce          289   630  0.458730\n",
       "Music              259   653  0.396631\n",
       "Photos             251   549  0.457195\n",
       "...                ...   ...       ...\n",
       "Location             0     8  0.000000\n",
       "Loyalty              0     1  0.000000\n",
       "Lyrics               0    23  0.000000\n",
       "Machine Learning     0     1  0.000000\n",
       "3D                   0    22  0.000000\n",
       "\n",
       "[320 rows x 3 columns]"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stat_1 = data_edges.groupby(['mashup_c'])[['num','num2']].sum()\n",
    "stat_1 = stat_1.sort_values('num',ascending=False)\n",
    "stat_1['percent'] = stat_1['num']/ stat_1['num2']\n",
    "stat_1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "39ac66a1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>num</th>\n",
       "      <th>num2</th>\n",
       "      <th>percent</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mashup_c</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Blockchain</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mail</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Nutrition</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Electronic Signature</th>\n",
       "      <td>88</td>\n",
       "      <td>99</td>\n",
       "      <td>0.888889</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mapping</th>\n",
       "      <td>1064</td>\n",
       "      <td>1692</td>\n",
       "      <td>0.628842</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Telephony</th>\n",
       "      <td>79</td>\n",
       "      <td>148</td>\n",
       "      <td>0.533784</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Calendars</th>\n",
       "      <td>11</td>\n",
       "      <td>22</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Payments</th>\n",
       "      <td>6</td>\n",
       "      <td>12</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Goals</th>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Internet of Things</th>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Fax</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Spam</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Project Management</th>\n",
       "      <td>6</td>\n",
       "      <td>13</td>\n",
       "      <td>0.461538</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>eCommerce</th>\n",
       "      <td>289</td>\n",
       "      <td>630</td>\n",
       "      <td>0.458730</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Video</th>\n",
       "      <td>188</td>\n",
       "      <td>411</td>\n",
       "      <td>0.457421</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Photos</th>\n",
       "      <td>251</td>\n",
       "      <td>549</td>\n",
       "      <td>0.457195</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Translation</th>\n",
       "      <td>8</td>\n",
       "      <td>19</td>\n",
       "      <td>0.421053</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Bots</th>\n",
       "      <td>2</td>\n",
       "      <td>5</td>\n",
       "      <td>0.400000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Forms</th>\n",
       "      <td>2</td>\n",
       "      <td>5</td>\n",
       "      <td>0.400000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Music</th>\n",
       "      <td>259</td>\n",
       "      <td>653</td>\n",
       "      <td>0.396631</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       num  num2   percent\n",
       "mashup_c                                  \n",
       "Blockchain               1     1  1.000000\n",
       "Mail                     1     1  1.000000\n",
       "Nutrition                1     1  1.000000\n",
       "Electronic Signature    88    99  0.888889\n",
       "Mapping               1064  1692  0.628842\n",
       "Telephony               79   148  0.533784\n",
       "Calendars               11    22  0.500000\n",
       "Payments                 6    12  0.500000\n",
       "Goals                    2     4  0.500000\n",
       "Internet of Things       2     4  0.500000\n",
       "Fax                      1     2  0.500000\n",
       "Spam                     1     2  0.500000\n",
       "Project Management       6    13  0.461538\n",
       "eCommerce              289   630  0.458730\n",
       "Video                  188   411  0.457421\n",
       "Photos                 251   549  0.457195\n",
       "Translation              8    19  0.421053\n",
       "Bots                     2     5  0.400000\n",
       "Forms                    2     5  0.400000\n",
       "Music                  259   653  0.396631"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stat_1 = data_edges.groupby(['mashup_c'])[['num','num2']].sum()\n",
    "\n",
    "stat_1['percent'] = stat_1['num']/ stat_1['num2']\n",
    "stat_4 = stat_1.sort_values(by = ['percent','num'],ascending=False)\n",
    "stat_4.iloc[:20]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "ec5d9b19",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>num</th>\n",
       "      <th>num2</th>\n",
       "      <th>percent</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mashup_c</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Mapping</th>\n",
       "      <td>1064</td>\n",
       "      <td>1692</td>\n",
       "      <td>0.628842</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Social</th>\n",
       "      <td>304</td>\n",
       "      <td>771</td>\n",
       "      <td>0.394293</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>eCommerce</th>\n",
       "      <td>289</td>\n",
       "      <td>630</td>\n",
       "      <td>0.458730</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Music</th>\n",
       "      <td>259</td>\n",
       "      <td>653</td>\n",
       "      <td>0.396631</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Photos</th>\n",
       "      <td>251</td>\n",
       "      <td>549</td>\n",
       "      <td>0.457195</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Video</th>\n",
       "      <td>188</td>\n",
       "      <td>411</td>\n",
       "      <td>0.457421</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Search</th>\n",
       "      <td>168</td>\n",
       "      <td>682</td>\n",
       "      <td>0.246334</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Electronic Signature</th>\n",
       "      <td>88</td>\n",
       "      <td>99</td>\n",
       "      <td>0.888889</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Telephony</th>\n",
       "      <td>79</td>\n",
       "      <td>148</td>\n",
       "      <td>0.533784</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Messaging</th>\n",
       "      <td>65</td>\n",
       "      <td>257</td>\n",
       "      <td>0.252918</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Travel</th>\n",
       "      <td>49</td>\n",
       "      <td>382</td>\n",
       "      <td>0.128272</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Widgets</th>\n",
       "      <td>45</td>\n",
       "      <td>148</td>\n",
       "      <td>0.304054</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>News Services</th>\n",
       "      <td>31</td>\n",
       "      <td>281</td>\n",
       "      <td>0.110320</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Jobs</th>\n",
       "      <td>31</td>\n",
       "      <td>87</td>\n",
       "      <td>0.356322</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Weather</th>\n",
       "      <td>28</td>\n",
       "      <td>113</td>\n",
       "      <td>0.247788</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Bookmarks</th>\n",
       "      <td>27</td>\n",
       "      <td>87</td>\n",
       "      <td>0.310345</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Sports</th>\n",
       "      <td>25</td>\n",
       "      <td>195</td>\n",
       "      <td>0.128205</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Government</th>\n",
       "      <td>25</td>\n",
       "      <td>98</td>\n",
       "      <td>0.255102</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Real Estate</th>\n",
       "      <td>22</td>\n",
       "      <td>138</td>\n",
       "      <td>0.159420</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Events</th>\n",
       "      <td>22</td>\n",
       "      <td>130</td>\n",
       "      <td>0.169231</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       num  num2   percent\n",
       "mashup_c                                  \n",
       "Mapping               1064  1692  0.628842\n",
       "Social                 304   771  0.394293\n",
       "eCommerce              289   630  0.458730\n",
       "Music                  259   653  0.396631\n",
       "Photos                 251   549  0.457195\n",
       "Video                  188   411  0.457421\n",
       "Search                 168   682  0.246334\n",
       "Electronic Signature    88    99  0.888889\n",
       "Telephony               79   148  0.533784\n",
       "Messaging               65   257  0.252918\n",
       "Travel                  49   382  0.128272\n",
       "Widgets                 45   148  0.304054\n",
       "News Services           31   281  0.110320\n",
       "Jobs                    31    87  0.356322\n",
       "Weather                 28   113  0.247788\n",
       "Bookmarks               27    87  0.310345\n",
       "Sports                  25   195  0.128205\n",
       "Government              25    98  0.255102\n",
       "Real Estate             22   138  0.159420\n",
       "Events                  22   130  0.169231"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stat_1.iloc[:20]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "29e6c526",
   "metadata": {},
   "outputs": [],
   "source": [
    "stat_2= data_edges.groupby(['source'])[['num','num2']].sum()\n",
    "stat_3 = stat_2.sort_values('num',ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "5cdbe0a6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>num</th>\n",
       "      <th>num2</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>source</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Mashup: Gawkk.com</th>\n",
       "      <td>14</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mashup: Pixelpipe</th>\n",
       "      <td>11</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mashup: Sociotoco Search</th>\n",
       "      <td>10</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mashup: G4ng</th>\n",
       "      <td>9</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mashup: Your Mapper</th>\n",
       "      <td>8</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mashup: LocAlerts</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mashup: LocaFollow</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mashup: Locago</th>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mashup: Local Area Info from Zillow Widget</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mashup: zangoa</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>6071 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                            num  num2\n",
       "source                                               \n",
       "Mashup: Gawkk.com                            14    23\n",
       "Mashup: Pixelpipe                            11    28\n",
       "Mashup: Sociotoco Search                     10    24\n",
       "Mashup: G4ng                                  9    20\n",
       "Mashup: Your Mapper                           8    17\n",
       "...                                         ...   ...\n",
       "Mashup: LocAlerts                             0     3\n",
       "Mashup: LocaFollow                            0     3\n",
       "Mashup: Locago                                0     5\n",
       "Mashup: Local Area Info from Zillow Widget    0     1\n",
       "Mashup: zangoa                                0     1\n",
       "\n",
       "[6071 rows x 2 columns]"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stat_3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3ee7c5c4",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
